package com.example.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
public class RunApp {

	private static Logger log = LoggerFactory.getLogger(RunApp.class);

	public static void main(String[] args) throws UnknownHostException {
		ConfigurableApplicationContext application = SpringApplication.run(RunApp.class, args);
		ConfigurableEnvironment env = application.getEnvironment();
		String ip = InetAddress.getLocalHost().getHostAddress();
		String port = env.getProperty("server.port");
		String path = String.valueOf(env.getProperty("server.servlet.context-path"));
		path = "null".equals(path) ? "" : path;
		log.info("\n-----------------------------------------------\n" +
				"本地: \t\thttp://localhost:" + port + path + "/\n" +
				"ip: \t\thttp://" + ip + ":" + port + path + "/\n" +
				"-----------------------------------------------");
	}

}
